package com.example.firstapp.KtLesson

fun main() {
    // lambda
    var array:Array<Int> = arrayOf(1,2,3,4,5)

    tramsform(array, action = {index: Int, item: Int -> index*item })
    tramsform(array){index: Int, item: Int -> index*item }
}

fun tramsform(array: Array<Int>,action:(index:Int,item:Int)->Int){
    for ( i in array.indices){
        array[i] = action(i, array[i])
    }
    // 只有一个参数时使用
    array.forEach {
        println(it)
    }
}